package com.javabasic.algorithm.leetcode;

import java.util.Scanner;

public class abc {
    static Scanner cin = new Scanner(System.in);

    public static void main(String[] args) {
        String str = cin.next();

        int len = str.length();
        int A = 0, AB = 0, ABC = 0;
        for (int i = 0; i < len; i++) {
            if (str.charAt(i) == 'a') {
                A++;
            } else if (str.charAt(i) == 'b') {
                AB += A;
            } else if (str.charAt(i) == 'c') {
                ABC += AB;
            }
        }
        System.out.println(ABC);
    }
}
